<template>
  <div>
    <el-dialog
      title="新建审批"
      :visible.sync="dialogVisible"
      width="680px"
      top="5vh"
      :append-to-body="true"
      :close-on-click-modal="false"
      class="dt-approval-card"
      @close="closeDialog"
    >
      <el-form :model="ApprovalForm" :rules="ApprovalRule" ref="ApprovalForm" label-width="120">
        <el-form-item label="审批类型" prop="auditType">
          <el-select
            v-model="ApprovalForm.auditType"
            placeholder="请选择审批类型"
            @change="changeType"
            :disabled="!!this.rootProjectId && !!this.taskId"
            size="medium"
          >
            <el-option label="发起审图" value="1"></el-option>
            <el-option label="任务进度" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="选择项目" prop="projectId">
          <el-select
            v-model="ApprovalForm.projectId"
            placeholder="请选择项目"
            @change="changeProject"
            clearable
            @clear="clrearProject"
            :disabled="!!this.rootProjectId"
            size="medium"
          >
            <!--  -->
            <el-option v-for="item in projectList" :label="item.projectName" :value="item.rootProjectId + ''" :key="item.rootProjectId"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="选择任务" prop="taskId">
          <el-select
            v-model="ApprovalForm.taskId"
            placeholder="请选择任务"
            @change="changeTask"
            clearable
            @clear="clearTask"
            :disabled="!!this.taskId"
            size="medium"
          >
            <!--  -->
            <el-option v-for="item in taskList" :label="item.taskName" :value="item.id + ''" :key="item.id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="任务截止时间">
          <span>{{ this.currentTask ? this.currentTask.endTime.substring(0, 10) : '--' }}</span>
          <span v-if="currentTask && currentTask.remainDays >= 0" class="ml">剩余{{ this.currentTask.remainDays }}天</span>
          <span v-if="currentTask && currentTask.remainDays < 0" class="ml bgr">延期{{ Math.abs(this.currentTask.remainDays) }}天</span>
        </el-form-item>
        <el-form-item label="延期原因" v-if="currentTask && currentTask.remainDays < 0" prop="delayReason">
          <el-input type="textarea" placeholder="请填写延期原因" v-model="ApprovalForm.delayReason" maxlength="200" show-word-limit :rows="4">
          </el-input>
        </el-form-item>
        <el-form-item label="审批人" v-if="ApprovalForm.auditType == '2'" prop="auditName">
          <el-input placeholder="请输入内容" v-model="auditName" :disabled="true" size="medium"> </el-input>
        </el-form-item>
        <el-form-item label="当前完成进度" v-if="ApprovalForm.auditType == '2'">
          <el-input placeholder="0%" v-model="progress" :disabled="true" size="medium"> </el-input>
        </el-form-item>
        <el-form-item label="本次工作进度" v-if="ApprovalForm.auditType == '2'" prop="progress">
          <el-input placeholder="请填写您的工作进度" v-model="ApprovalForm.progress" @input="handleInput" size="medium">
            <i slot="suffix">%</i>
          </el-input>
        </el-form-item>
        <el-form-item label="审批流程" v-if="ApprovalForm.auditType == '1'">
          <div class="dt-content-approval">
            <div class="dt-content-approval-steps" v-if="currentTask && currentTask.jdUid">
              <p>{{ currentTask.jdName.substr(-2) }}</p>
              <p :class="{ 'dt-content-approval-red': currentTask.buttonState == 5 }">校对</p>
            </div>
            <div
              class="dashed-border"
              v-if="currentTask && ((currentTask.jdUid && currentTask.shUid) || (currentTask.jdUid && currentTask.sdUid))"
            ></div>
            <div class="dt-content-approval-steps" v-if="currentTask && currentTask.shUid">
              <p>{{ currentTask.shName.substr(-2) }}</p>
              <p :class="{ 'dt-content-approval-red': currentTask.buttonState == 7 }">审核</p>
            </div>
            <div class="dashed-border" v-if="currentTask && currentTask.shUid && currentTask.sdUid"></div>
            <div class="dt-content-approval-steps" v-if="currentTask && currentTask.sdUid">
              <p>{{ currentTask.sdName.substr(-2) }}</p>
              <p :class="{ 'dt-content-approval-red': currentTask.buttonState == 9 }">审定</p>
            </div>
          </div>
        </el-form-item>
        <el-form-item label="提交成果" v-if="ApprovalForm.auditType == '1'" prop="fileList">
          <el-upload
            action="#"
            :http-request="httpRequest"
            :show-file-list="false"
            :on-change="handleChange"
            :file-list="this.ApprovalForm.fileList"
            :limit="5"
            :before-upload="beforeAvatarUpload"
            :on-exceed="handleExceed"
            class="dt-content-approval-upload"
          >
            <el-button slot="trigger" size="small" icon="el-icon-upload2">选取文件</el-button>
            <div slot="tip" class="el-upload__tip">单个文件小于50M，最多可以上传5个附件</div>
          </el-upload>
          <div v-for="item in this.ApprovalForm.fileList" :key="item.uid">
            <div class="dt-content-approval-achievement">
              <span v-if="item.isCanReName" :title="item.name" class="dt-content-approval-filename"
                ><i class="el-icon-document" style="margin-right: 4px"></i>{{ item.name }}</span
              >
              <el-input v-model="item.newFileName" placeholder="请输入文件名" size="mini" maxlength="40" v-if="!item.isCanReName"></el-input>
              <span>{{ Uname }}</span>
              <span class="dt-content-approval-btn" v-if="item.isCanReName">
                <el-button type="text" size="mini" @click="reName(item)">重命名</el-button>
                <el-button type="text" size="mini" @click="handleRemove(item)">删除</el-button>
              </span>
              <span class="dt-content-approval-btn" v-if="!item.isCanReName">
                <el-button type="text" size="mini" @click="sureReName(item)">确定</el-button>
                <el-button type="text" size="mini" @click="reName(item)">取消</el-button>
              </span>
            </div>
            <div>
              <el-progress v-if="item.percentage !== 100" :percentage="item.percentage" :stroke-width="2"></el-progress>
            </div>
          </div>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submit('ApprovalForm')" :loading="sendLock" size="medium">确定</el-button
        ><el-button @click="closeDialog" size="medium">取消</el-button>
      </div>
    </el-dialog>
    <el-dialog title="" :visible.sync="isShowImage" :append-to-body="true" :before-close="closeShow">
      <el-image :src="imgSrc" fit="fill" v-if="imgSrc"></el-image>
      <iframe
        v-if="fileSrc"
        :src="`https://view.officeapps.live.com/op/view.aspx?src=${fileSrc}`"
        width="100%"
        height="800px"
        frameBorder="0"
      ></iframe>
    </el-dialog>
  </div>
</template>
<script>
export default {
  head() {
    return {
      script: [
        {
          type: 'text/javascript',
          src: 'https://www.ccccdt.com/skb/js/oos-sdk-6.0.min.js',
          body: false
        }
      ]
    }
  },
  props: {
    rootProjectId: String,
    taskId: String,
    auditType: String
  },
  watch: {
    // 监听isVisible的变化
    dialogVisible(newValue, oldValue) {
      if (newValue) {
        // 当组件变为可见时调用接口
        if (this.rootProjectId || this.taskId) {
          this.ApprovalForm.auditType = this.auditType || '2'
          this.ApprovalForm.projectId = this.rootProjectId
          this.ApprovalForm.taskId = this.taskId
          this.getTaskList(this.auditType, this.rootProjectId, this.taskId)
        } else {
          this.getTaskList(this.auditType, this.rootProjectId, this.taskId)
        }
      }
    }
    // auditType: function (newVal, oldVal) {
    //   if (newVal !== oldVal) {
    //     if (this.rootProjectId || this.taskId) {
    //       this.ApprovalForm.auditType = this.auditType || '2'
    //       this.ApprovalForm.projectId = this.rootProjectId
    //       this.ApprovalForm.taskId = this.taskId
    //       this.getTaskList(this.auditType, this.rootProjectId, this.taskId)
    //     }
    //   }
    // },
    // rootProjectId: function (newVal, oldVal) {
    //   if (newVal !== oldVal) {
    //     if (this.rootProjectId || this.taskId) {
    //       this.ApprovalForm.auditType = this.auditType || '2'
    //       this.ApprovalForm.projectId = this.rootProjectId
    //       this.ApprovalForm.taskId = this.taskId
    //       this.getTaskList(this.auditType, this.rootProjectId, this.taskId)
    //     }
    //   }
    // },
    // taskId: function (newVal, oldVal) {
    //   if (newVal !== oldVal) {
    //     if (this.rootProjectId || this.taskId) {
    //       this.ApprovalForm.auditType = this.auditType || '2'
    //       this.ApprovalForm.projectId = this.rootProjectId
    //       this.ApprovalForm.taskId = this.taskId
    //       this.getTaskList(this.auditType, this.rootProjectId, this.taskId)
    //     }
    //   }
    // }
  },
  data() {
    return {
      dialogVisible: false,
      ApprovalForm: {
        auditType: '2',
        projectId: '',
        taskId: '',
        delayReason: '',
        progress: '',
        fileList: [],
        auditName: ''
      },
      ApprovalRule: {
        // auditType:[],
        // auditType: [
        //   { required: true, message: '请选择审批类型', trigger: 'blur' },
        //   { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        // ],
        progress: [{ required: true, message: '请输入完成进度', trigger: 'blur' }],
        auditType: [{ required: true, message: '请选择审批类型', trigger: 'change' }],
        projectId: [{ required: true, message: '请选择项目', trigger: 'change' }],
        taskId: [{ required: true, message: '请选择任务', trigger: 'change' }],
        delayReason: [{ required: true, message: '请填写延期原因', trigger: 'blur' }],
        auditName: [{ required: true, message: '请输入审批人', trigger: 'blur' }],
        fileList: [{ required: true, message: '请选择文件', trigger: 'change' }]
      },
      Uid: this.$tools.getDecrypt(this.$store.state.uid), //用户id,
      Uname: decodeURIComponent(this.$store.state.uname),
      projectList: [], //项目列表
      taskList: [],
      projectListCopy: [], //项目列表副本,
      taskListCopy: [], //任务列表副本,
      currentTask: null, //当前任务
      currentProject: null, //当前项目
      imgSrc: '',
      isShowImage: false,
      fileSrc: '',
      newFileName: '',
      sendLock: false
    }
  },
  computed: {
    daysDifference() {
      if (!this.currentTask || !this.currentTask.endTime) {
        return '--' // 如果currentTask不存在或endTime未定义，则显示'--'
      }
      return this.calculateDaysDifference(this.currentTask.endTime)
    },
    auditName() {
      // 使用计算属性来处理逻辑
      return this.currentTask ? this.currentTask.auditName || '' : ''
    },
    progress() {
      return this.currentTask ? this.currentTask.progress + '%' || '' : ''
    }
  },

  methods: {
    /** ********************** 正式代码*****************  */
    showApproval() {
      this.dialogVisible = true
      this.$nextTick(() => {
        if (!!this.$refs.ApprovalForm) {
          this.$refs.ApprovalForm.clearValidate()
        }
      })
    },
    getTaskList(auditType = this.ApprovalForm.auditType, rootProjectId = '', taskId = '') {
      var data = [{ userId: this.Uid, auditType: auditType, rootProjectId: rootProjectId, taskId: taskId }],
        domain = [this.$store.state.DOMAIN],
        path = ['/project/task/taskSelector'],
        dataAxios = this.$tools.getDataAxios(this, domain, path, data)
      Promise.all(dataAxios)
        .then((response) => {
          this.$tools.callbackAxios(this, response, (response) => {
            var data = response[0].data
            if (data.code === 200) {
              this.projectList = data.data
              this.taskList = data.data.flatMap((item) => item.taskList)
              this.projectListCopy = data.data
              this.taskListCopy = data.data.flatMap((item) => item.taskList)
              if (this.rootProjectId && this.taskId) {
                this.currentTask = this.taskList[0]
                this.currentProject = this.projectList[0]
                this.ApprovalForm.auditName = this.currentTask.auditName
              }
            }
          })
        })
        .catch((error) => {})
    },
    changeProject(projectId) {
      this.ApprovalForm.taskId = ''
      this.taskList = this.projectList.find((item) => item.rootProjectId == projectId)
        ? this.projectList.find((item) => item.rootProjectId == projectId).taskList
        : []
      this.currentProject = this.projectList.find((item) => item.rootProjectId == projectId)
    },
    changeTask(taskId) {
      if (taskId) {
        this.ApprovalForm.projectId = this.taskList.find((item) => item.id == taskId)
          ? this.taskList.find((item) => item.id == taskId).rootProjectId + ''
          : ''

        this.currentTask = this.taskList.find((item) => item.id == taskId)
        this.ApprovalForm.auditName = this.currentTask.auditName
      }
    },
    clearTask() {
      this.projectList = this.projectListCopy
      this.taskList = this.taskListCopy
    },
    clrearProject() {
      this.projectList = this.projectListCopy
      this.taskList = this.taskListCopy
    },

    calculateDaysDifference(dateString) {
      // 将输入的日期字符串转换为Date对象，并仅提取年、月、日
      const inputDate = new Date(dateString)
      const inputYear = inputDate.getFullYear()
      const inputMonth = inputDate.getMonth()
      const inputDay = inputDate.getDate()

      // 获取当前日期的年、月、日
      const currentDate = new Date()
      const currentYear = currentDate.getFullYear()
      const currentMonth = currentDate.getMonth()
      const currentDay = currentDate.getDate()

      // 计算两个日期之间的差异天数
      // 创建一个新的日期对象，用于比较
      const date1 = new Date(inputYear, inputMonth, inputDay)
      const date2 = new Date(currentYear, currentMonth, currentDay)

      // 计算两个日期之间的时间差（以毫秒为单位）
      const timeDifference = date1 - date2

      // 将时间差转换为天数，并包括起始日期
      const daysDifference = Math.ceil(timeDifference / (1000 * 60 * 60 * 24))

      return daysDifference
    },
    /* *************上传文件操作******************** */
    handleChange(file, fileList) {
      var url = 'https://www.ccccdt.com/ccccdt/' + file.raw.key
      file = {
        ...file,
        key: null,
        url: url,
        createUid: this.Uid,
        isCanReName: true,
        newFileName: ''
      }

      this.ApprovalForm.fileList = [...this.ApprovalForm.fileList, file]
      this.sendLock = true
    },
    httpRequest(req) {
      this.$tools.getStsClient(this, req.file, (state, client, bucketName, file) => {
        if (state) {
          this.uploadFile(client, bucketName, file)
        }
      })
    },

    uploadFile(client, bucketName, file) {
      var time = new Date().getTime() + '',
        key = time.split('').reverse().join('') + this.$tools.getRandomName(file)
      var params = {
        Body: file,
        Bucket: bucketName,
        Key: key,
        ContentDisposition: `attachment; filename="${encodeURIComponent(file.name)}"`
      }
      client
        .putObject(params, (err, data) => {
          if (err) {
          } else {
            this.onSuccess(file, key)
          }
        })
        .on('httpUploadProgress', (progress) => {
          this.onProgress(progress, file)
        })
    },
    onSuccess(file, key) {
      this.ApprovalForm.fileList.forEach((item) => {
        if (item.uid == file.uid) {
          item.status = 'success'
          item.key = key
          item.url = 'https://www.ccccdt.com/ccccdt/' + key
        }
      })
      this.sendLock = false
      this.$refs['ApprovalForm'].validateField('fileList')
    },
    onProgress(progress, file) {
      if (progress.lengthComputable) {
        var index = this.ApprovalForm.fileList.findIndex((item) => item.uid === file.uid)
        this.ApprovalForm.fileList[index].percentage = Number(((progress.loaded / progress.total) * 100).toFixed(0))
      }
    },
    handleRemove(file) {
      this.ApprovalForm.fileList = this.ApprovalForm.fileList.filter((item) => item.uid !== file.uid)
      this.$refs['ApprovalForm'].validateField('fileList')
    },
    // handlePreview(file) {
    //   var suffix = file.name.substring(file.name.lastIndexOf('.') + 1)
    //   const supportedImageSuffixes = ['png', 'jpg', 'jpeg', 'gif', 'svg', 'ico', 'bmp']
    //   const officeArr = ['docx', 'xlsx', 'ppt', 'txt', 'doc', 'xls', , 'pdf', 'pptx']
    //   if (supportedImageSuffixes.includes(suffix)) {
    //     this.isShowImage = true
    //     this.imgSrc = this.$tools.getStsFileUrl(this.$store.state.uid, 'https://www.ccccdt.com/ccccdt/' + file.key)
    //   }
    //   if (officeArr.includes(suffix)) {
    //     this.isShowImage = true
    //     this.fileSrc = this.$tools.getStsFileUrl(this.$store.state.uid, 'https://www.ccccdt.com/ccccdt/' + file.key)
    //   }

    //   // if (suffix == 'txt') {
    //   // }
    //   // if (suffix == 'doc') {
    //   // }
    //   // if (suffix == 'docx') {
    //   // }
    //   // if (suffix == 'xls') {
    //   // }
    //   // if (suffix == 'xlsx') {
    //   // }
    //   // if (suffix == 'pdf') {
    //   //   this.isShowImage = true
    //   //   this.fileSrc = file.url
    //   // }
    //   // if (suffix == 'pptx') {
    //   // }
    //   // if (suffix == 'ppt') {
    //   // }
    // },
    beforeAvatarUpload(file) {
      const isLt2M = file.size / 1024 / 1024 < 50
      if (!isLt2M) {
        this.$message.error('上传文件大小不能超过 50MB!')
        // 找到要删除的对象的索引
        let index = this.ApprovalForm.fileList.findIndex((item) => item.uid === file.uid)
        // 如果找到了对象，使用splice方法删除它
        if (index !== -1) {
          this.ApprovalForm.fileList.splice(index, 1)
        }
      }
      return isLt2M
    },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 5 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`)
      // if (this.formData.fileList.length > 5) {
      //   this.$message.warning(`当前限制只能选择 5 个文件`)
      // }
      // this.$message.warning()
    },
    /*************************** 文件上传结束***********************************************************/
    closeShow(done) {
      this.imgSrc = ''
      this.fileSrc = ''
      done()
    },
    reName(file) {
      file.isCanReName = !file.isCanReName
      file.newFileName = file.name.substring(0, file.name.lastIndexOf('.'))
    },
    async sureReName(item) {
      if (item.newFileName == '') {
        this.$message('请输入新的文件名')
      } else {
        var isSuccess = await this.resetTyyFileName(item.newFileName + item.name.substring(item.name.lastIndexOf('.')), item.key)
        if (isSuccess) {
          item.name = item.newFileName + isSuccess.substring(isSuccess.lastIndexOf('.'))
          item.isCanReName = !item.isCanReName
          item.url = 'https://www.ccccdt.com/ccccdt/' + isSuccess
        }
        // this.$tools.getStsClient(this, item.raw, (state, client, bucketName, file) => {
        //   if (state) {
        //     var time = new Date().getTime() + '',
        //       key = time.split('').reverse().join('') + this.$tools.getRandomName(item)
        //     var params = {
        //       Bucket: bucketName,
        //       CopySource: `${bucketName}/${item.key}`,
        //       Key: key,
        //       ContentDisposition: `attachment; filename="${encodeURIComponent(item.newFileName)}"`
        //     }
        //     client.copyObject(params, (err, data) => {
        //       if (err) {
        //         console.error('copy fail', err)
        //       } else {
        //         item.name = item.newFileName
        //         item.isCanReName = !item.isCanReName
        //         item.url = 'https://www.ccccdt.com/ccccdt/' + key
        //         console.log(item, '---------')
        //       }
        //     })
        //   }
        // })
      }
    },
    // 文件重命名
    resetTyyFileName(fileName, objectName) {
      var data = [{ fileName: fileName, objectName: objectName, userId: this.Uid }],
        domain = [this.$store.state.DOMAIN],
        path = ['/project/cloud/resetTyyFileName'],
        dataAxios = this.$tools.getDataAxios(this, domain, path, data)
      return new Promise((resolve, reject) => {
        Promise.all(dataAxios)
          .then((response) => {
            this.$tools.callbackAxios(this, response, (response) => {
              var data = response[0].data
              if (data.code === 200) {
                resolve(data.data)
              } else {
                resolve(false)
              }
            })
          })
          .catch((error) => {
            console.error('发生错误:', error)
            reject(error)
          })
      })
    },
    closeDialog() {
      // this.$refs.ApprovalForm.resetFields()
      this.ApprovalForm.auditType = this.auditType ? this.auditType : '2'
      this.ApprovalForm.projectId = this.rootProjectId ? this.rootProjectId : ''
      this.ApprovalForm.taskId = this.taskId ? this.taskId : ''
      this.ApprovalForm.delayReason = ''
      this.ApprovalForm.progress = ''
      this.ApprovalForm.fileList = []
      this.ApprovalForm.auditName = ''
      this.dialogVisible = false
      this.$refs.ApprovalForm.clearValidate()
      // this.$destroy()
      //       ApprovalForm: {
      //   auditType: '2',
      //   projectId: '',
      //   taskId: '',
      //   delayReason: '',
      //   progress: '',
      //   fileList: [],
      //   auditName: ''
      // },
    },
    submit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.sendApproval()
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    handleInput(value) {
      // 使用正则表达式替换非正整数的输入
      this.ApprovalForm.progress = this.ApprovalForm.progress.replace(/[^\d]/g, '')
      // 转换为数字并检查范围
      let num = parseInt(this.ApprovalForm.progress, 10)
      let currentNum = Number.isNaN(parseInt(this.progress, 10)) ? 0 : parseInt(this.progress, 10)
      if (!isNaN(num)) {
        if (num < 1) {
          num = 1 // 如果小于1，则设置为1
        } else if (num + currentNum > 100) {
          num = 100 - currentNum // 如果大于100，则设置为100
        }
        // 将处理后的值赋回给inputValue
        this.ApprovalForm.progress = num.toString()
      } else {
        // 如果转换结果为NaN，则清空输入
        this.inputValue = ''
      }
    },
    sendApproval() {
      if (this.ApprovalForm.auditType == '2') {
        this.sendLock = true
        if (this.ApprovalForm.progress == '') {
          this.$message.error({
            message: '请填写进度',
            duration: 2000, // 消息显示5秒
            onClose: () => {
              this.sendLock = false
            } // 当消息关闭时执行的回调函数
          })
          //
          return
        }
        var data = [
            {
              userId: this.Uid,
              taskId: this.ApprovalForm.taskId,
              projectId: this.ApprovalForm.projectId,
              progress: this.ApprovalForm.progress,
              delayReason: this.ApprovalForm.delayReason
            }
          ],
          domain = [this.$store.state.DOMAIN],
          path = ['/project/taskAudit/addAuditProgress'],
          dataAxios = this.$tools.getDataAxios(this, domain, path, data)
        Promise.all(dataAxios)
          .then((response) => {
            this.$tools.callbackAxios(this, response, (response) => {
              var data = response[0].data
              if (data.code === 200) {
                this.sendLock = false
                // console.log('提交审批成功', data)
                this.dialogVisible = false
                this.$emit('updataList')
                this.$root.$emit('updataList')
              } else {
                this.sendLock = false
                this.$message.error(data.message)
              }
            })
          })
          .catch((error) => {})
      }
      if (this.ApprovalForm.auditType == '1') {
        this.sendLock = true
        var annexJson = this.ApprovalForm.fileList.map((item) => ({
          fileName: item.name,
          fileUrl: item.url,
          fileSize: item.size,
          createUid: item.createUid
        }))
        // var auditType
        // // console.log(this.currentTask, '当前任务')
        // if (this.currentTask && this.currentTask.jdUid) {
        //   auditType = '1'
        // } else if (this.currentTask && this.currentTask.shUid) {
        //   auditType = '2'
        // } else if (this.currentTask && this.currentTask.sdUid) {
        //   auditType = '3'
        // }
        var data = [
            {
              userId: this.Uid,
              taskId: this.ApprovalForm.taskId,
              projectId: this.ApprovalForm.projectId,
              // auditType: auditType,
              delayReason: this.ApprovalForm.delayReason,
              annexJson: JSON.stringify(annexJson)
            }
          ],
          domain = [this.$store.state.DOMAIN],
          path = ['/project/taskAudit/addAuditDrawing'],
          dataAxios = this.$tools.getDataAxios(this, domain, path, data)
        Promise.all(dataAxios)
          .then((response) => {
            this.$tools.callbackAxios(this, response, (response) => {
              var data = response[0].data
              if (data.code === 200) {
                this.sendLock = false
                // console.log(data, '提交成功')
                this.dialogVisible = false
                this.$emit('updataList')
                this.$root.$emit('updataList')
              } else {
                this.sendLock = false
                this.$message.error(data.message)
              }
            })
          })
          .catch((error) => {})
      }
    },
    // 重置表单
    resetForm() {
      if (!!this.$refs.ApprovalForm) {
        this.$refs.ApprovalForm.resetFields()
      }

      // this.ApprovalForm = {
      //   auditType: this.auditType || '2',
      //   // taskId: '',
      //   projectId: this.rootProjectId,
      //   progress: '',
      //   delayReason: '',
      //   fileList: []
      //   // auditName: ''
      // }
    },
    changeType(value) {
      this.ApprovalForm.taskId = ''
      this.getTaskList(this.auditType, this.rootProjectId, this.taskId)
    }
    /******  上传文件操作 ******/
  },
  mounted() {
    // console.log('审核类型')
    // this.ApprovalForm.auditType = this.auditType || '2'
    // this.getTaskList(this.auditType, this.rootProjectId, this.taskId)
    // setTimeout(() => {
    //   this.loading.mounted = false
    // }, 500)
  }
}
</script>
<style scoped>
.el-dialog__wrapper >>> .el-form-item {
  display: flex;
}
.el-dialog__wrapper >>> .el-form-item__content {
  flex: 1;
}
.el-dialog__wrapper >>> .el-form-item__label {
  width: 120px;
  text-align: left;
}
.el-dialog__wrapper >>> .el-select {
  width: 100%;
}
.dt-content-approval {
  display: flex;
  /* align-items: center; */
}
/* .dt-content-approval-steps {
  width: 36px;
  height: 36px;
} */
.dt-content-approval-steps p:nth-of-type(1) {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: #0077ff;
  text-align: center;
  line-height: 36px;
  color: #fff;
  font-size: 12px;
}
.dt-content-approval-steps p:nth-of-type(2) {
  text-align: center;
  line-height: 36px;
  font-size: 14px;
  color: #1f1f1f;
}
.dashed-border {
  /* border-top: 1px solid #e9eef7; 设置上边框为虚线，虚线间隙为2px */
  border-top: 1px dashed #e9eef7; /* 设置上边框为虚线，线宽为1px */
  /* border-top-color: #e9eef7; 设置上边框颜色，可根据需要修改 */
  /* 虚线间隙为2px的CSS原生支持并不直接，以下是一种近似实现方法 */
  /* background-image: linear-gradient(to right, transparent 50%, #e9eef7 50%);
  background-size: 2px 1px;
  background-repeat: repeat-x;
  background-position: top; */
  width: 40px; /* 设置宽度 */
  /* height: 1px; 设置高度 */
  margin-top: 18px;
}
.dt-content-approval-achievement {
  display: flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 4px;
  line-height: 28px;
  height: 28px;
}

.dt-content-input {
  width: 300px;
}
.dt-content-approval-achievement:hover {
  background-color: #f0f5ff;
}
.dt-content-approval-achievement span {
  font-size: 12px;
}
.dt-content-approval-achievement .dt-content-approval-filename {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 412px;
  margin-right: 20px;
}
.dt-content-approval-achievement .dt-content-approval-btn {
  margin-left: 30px;
}

.dt-content-approval-achievement .dt-content-approval-btn >>> .el-button span {
  font-size: 12px !important;
}
.el-dialog__wrapper >>> .el-dialog__footer {
  border-top: 1px solid #e9eef7;
}
.ml {
  margin-left: 10px;
}
.bgr {
  color: #f5222d;
}

.dt-content-approval-achievement >>> .el-input {
  flex: 1;
  margin-right: 32px;
}
::v-deep .el-progress__text {
  font-size: 12px !important;
}

/* 新建审批样式 */
.dt-approval-card >>> .el-dialog__header {
  padding-bottom: 0px;
}
.dt-approval-card >>> .el-dialog__body {
  padding-top: 20px;
  padding-bottom: 0px;
}
.dt-content-approval-upload {
  display: flex;
  align-items: center;
}
.dt-content-approval-upload >>> .el-upload__tip {
  margin-left: 10px;
  line-height: 1;
  margin-top: 0;
}

.dt-approval-card >>> .el-dialog__footer {
  padding: 12px 20px 12px 20px !important;
}
div.dt-content-approval-steps > p.dt-content-approval-red {
  color: red;
}
.dt-approval-card >>> .el-input__suffix {
  height: 36px;
}
</style>
